package com.ruoyi.system.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.GaExamPaperSubject;
import com.ruoyi.system.service.IGaExamPaperSubjectService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 考试试卷题目增删改查Controller
 * 
 * @author wzp
 * @date 2021-11-18
 */
@RestController
@RequestMapping("/kyga/examPaperSubject")
public class GaExamPaperSubjectController extends BaseController
{
    @Autowired
    private IGaExamPaperSubjectService gaExamPaperSubjectService;

    /**
     * 查询考试试卷题目增删改查列表
     */
    @PreAuthorize("@ss.hasPermi('kyga:examPaperSubject:list')")
    @GetMapping("/list")
    public TableDataInfo list(GaExamPaperSubject gaExamPaperSubject)
    {
        startPage();
        List<GaExamPaperSubject> list = gaExamPaperSubjectService.selectGaExamPaperSubjectList(gaExamPaperSubject);
        return getDataTable(list);
    }

    /**
     * 导出考试试卷题目增删改查列表
     */
    @PreAuthorize("@ss.hasPermi('kyga:examPaperSubject:export')")
    @Log(title = "考试试卷题目增删改查", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(GaExamPaperSubject gaExamPaperSubject)
    {
        List<GaExamPaperSubject> list = gaExamPaperSubjectService.selectGaExamPaperSubjectList(gaExamPaperSubject);
        ExcelUtil<GaExamPaperSubject> util = new ExcelUtil<GaExamPaperSubject>(GaExamPaperSubject.class);
        return util.exportExcel(list, "考试试卷题目增删改查数据");
    }

    /**
     * 获取考试试卷题目增删改查详细信息
     */
    @PreAuthorize("@ss.hasPermi('kyga:examPaperSubject:query')")
    @GetMapping(value = "/{examPaper}")
    public AjaxResult getInfo(@PathVariable("examPaper") Long examPaper)
    {
        return AjaxResult.success(gaExamPaperSubjectService.selectGaExamPaperSubjectByExamPaper(examPaper));
    }

    /**
     * 新增考试试卷题目增删改查
     */
    @PreAuthorize("@ss.hasPermi('kyga:examPaperSubject:add')")
    @Log(title = "考试试卷题目增删改查", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GaExamPaperSubject gaExamPaperSubject)
    {
        return toAjax(gaExamPaperSubjectService.insertGaExamPaperSubject(gaExamPaperSubject));
    }

    /**
     * 修改考试试卷题目增删改查
     */
    @PreAuthorize("@ss.hasPermi('kyga:examPaperSubject:edit')")
    @Log(title = "考试试卷题目增删改查", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GaExamPaperSubject gaExamPaperSubject)
    {
        return toAjax(gaExamPaperSubjectService.updateGaExamPaperSubject(gaExamPaperSubject));
    }

    /**
     * 删除考试试卷题目增删改查
     */
    @PreAuthorize("@ss.hasPermi('kyga:examPaperSubject:remove')")
    @Log(title = "考试试卷题目增删改查", businessType = BusinessType.DELETE)
	@DeleteMapping("/{examPapers}")
    public AjaxResult remove(@PathVariable Long[] examPapers)
    {
        return toAjax(gaExamPaperSubjectService.deleteGaExamPaperSubjectByExamPapers(examPapers));
    }
}
